import cv2 as cv
import numpy as np
img2 = cv.imread('left06.jpg',0)
img1 = cv.imread('chessboard.png',0)

def cv_show(name, img):
    cv.imshow(name, img)
    cv.waitKey(0)
    cv.destroyAllWindows()

sift =cv.xfeatures2d.SIFT_create()

kp1,des1 = sift.detectAndCompute(img1, None)
kp2,des2 = sift.detectAndCompute(img2, None)

bf = cv.BFMatcher(crossCheck = True)

bf = cv.BFMatcher()
matches =bf.knnMatch(des1, des2, k=2)
good = []

for m,n in matches:
    if m.distance < 0.75*n.distance:
        good.append([m])

img3 = cv.drawMatchesKnn(img1, kp1,img2,kp2,good,None,flags=2)
cv.imshow('ORB', img3)
cv.imwrite('ORB.png', img3)
if cv.waitKey(0) & 0xff == 27:
	cv.destroyAllWindows()
